<tagLib name="html" />
<include file="Public:header" />
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
<!--  功能组区域  -->
<div class="btn-toolbar">
	<div class="btn-group">
		<button class="btn btn-primary" onclick="tocheck()"> <i class="icon-check icon-white"></i>
			待审核
		</button>
		<!--
		<button class="btn btn-primary" onclick="toshipping()"> <i class="icon-check icon-white"></i>
			待平台发货
		</button>
	-->
		<button class="btn btn-primary" onclick="add()"> <i class="icon-plus icon-white"></i>
			新增
		</button>
  	   <button class="btn btn-primary" onclick="print()"><i class="icon-print icon-white"></i> 打印出库单</button>
		<button class="btn btn-primary" onclick="foreverdel()"> <i class="icon-trash icon-white"></i>
			删除
		</button>
	
	</div>
		导出
		<a href="__URL__/export_order?{$parameters}&etype=order&action={:ACTION_NAME}" class="btn">订单</a>
		<a href="__URL__/export_order?{$parameters}&etype=detail&action={:ACTION_NAME}" class="btn">商品</a>
		<a href="__URL__/export_order?{$parameters}&etype=both&action={:ACTION_NAME}" class="btn">全部</a>
	<form class="search-form" method='get' action="__URL__">

		每页显示 <input type="text" class="span1" name="listRows" value="{$_REQUEST.listRows}">
		{:configList( C('orderStatus'),$_REQUEST['order_status'],'order_status' )}
		{:configList( C('Wholesale_source'),$_REQUEST['order_source_id'],'order_source_id' )}
		<select name="time_type" class="span2"> 
			<option value="">--选择时间类型--</option>
			<option value="1" <eq name="_REQUEST.time_type" value="1">selected</eq> >审核时间</option> 
			<option value="2" <eq name="_REQUEST.time_type" value="2">selected</eq> >发货时间</option> 
			<option value="3" <eq name="_REQUEST.time_type" value="3">selected</eq> >下单时间</option> 
			<option value="4" <eq name="_REQUEST.time_type" value="4">selected</eq> >支付时间</option>
		</select>
		从<input type="text" class="span2"  name="start_time" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<notempty name='_REQUEST.start_time'>{$_REQUEST.start_time}</notempty>">
		到<input type="text" class="span2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="end_time" id="end_time" value="<notempty name='_REQUEST.end_time'>{$_REQUEST.end_time}</notempty>" >

		<input type="text" class="search-query span2" name="keywords" <notempty name='_REQUEST.keywords'>
		<php>echo 'value="'.urldecode($_REQUEST['keywords']).'"'</php>
		<else/>
		placeholder="按产品,发货信息,或物流信息搜索"
	</notempty>
	>订单号
	<input type="text" class="search-query span2" name="order_no" <notempty name='_REQUEST.order_no'>
		<php>echo 'value="'.urldecode($_REQUEST['order_no']).'"'</php>
		<else/>
		placeholder="按订单号搜索"
	</notempty>
	>
	<input type="submit" class="btn btn-primary" value="搜索">
	</form>
	
</div>
<!-- 功能组区域结束 -->
<php>
    
    function editLink($id){
     echo ('<a href="__APP__/Wholesale/edit/id/'.$id.'">'.getModelName($id,"Wholesale","wholesale_no").'</a>');
	}

	
</php>
<!-- 列表显示区域  -->
<div class="list" >
<div id="result" class="result none"></div><html:list id="checkList" pk="id" action="true" style="table table-bordered table-striped table-striped" checkbox="true"  datasource="list" show="id:编号|3%:edit,id|editLink:订单号|4%,total:总货款,sum_number:总数,customer_name:客户,logicompany_id|getModelName='Logicompany':配送公司,logino:运单号,order_status|getConfigVal=orderstatus:订单状态,remark:备注|10%,create_time|toDate:创建时间,shipping_time|toDate:发货时间,wholesale_source_id|getConfigVal='wholesale_source':订单来源,status|getStatus:审核" actionlist="edit:详情:id"/>
</div>
<!--  分页显示区域 -->
<div class="page">{$page}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<include file="Public:footer"/>
<load href="__PUBLIC__/Js/My97DatePicker/WdatePicker.js" />
<script type="text/javascript">
	//增录产品
  function addpt(id){
    window.open( APP+"/Sale_detail/add/id/"+id, '_blank' );
  }
  function addWholesale(){
    window.open( APP+"/Sale/addWholesale/", '_blank' );
  }

  //待平台发货的订单
  function toshipping(){
    window.open( URL+"/toshipping", '_blank' );
  }

  //缺货不能发货的订单
  function can_not_shipping(){
    window.open( URL+"/can_not_shipping", '_blank' );
  }

  //平台已发货
  function setshipping(id,sale_no,express,logino){
	if (id=='')
	{
		alert('请选择订单！');
		return false;
	}
	//TODO 只有等待发货的订单才能改变为平台已发货状态
	window.open("http://dealer.yaofang.cn/order/detail/"+sale_no,'_blank');
    location.href = URL+"/setFieldValue/id/"+id+"/field/is_shipping_mall/new/1";
        
}

  //填写快递单号，TODO置为发货状态
  function doshipping(id){
  var keyValue = (id)? id : getSelectCheckboxValues();
	if (keyValue=='')
	{
		alert('请选择订单！');
		return false;
	}
    window.open( APP+"/Sale/doshipping/oid/"+keyValue, '_blank' );
  }

//批量填写快递单号，TODO置为发货状态
  function mass_doshipping(id){
  var keyValue = (id)? id : getSelectCheckboxValues();
	if (keyValue=='')
	{
		alert('请选择订单！');
		return false;
	}
    window.open( APP+"/Sale/mass_doshipping/oid/"+keyValue, '_blank' );
  }

  function import_order(){
    location.href= APP+'/Sale/tbimport';
 }

 function invoice(id){
 	var keyValue = (id)? id : getSelectCheckboxValues();
	if (keyValue=='')
	{
		alert('请选择订单！');
		return false;
	}
        window.open(URL+"/invoice/oid/"+keyValue,'_blank' );
 }
 function shipping(id){
 	var keyValue = (id)? id : getSelectCheckboxValues();
	if (keyValue=='')
	{
		alert('请选择订单！');
		return false;
	}
        location.href = URL+"/shipping/oid/"+keyValue;
 }
 function pick_goods(id){
 	var keyValue = (id)? id : getSelectCheckboxValues();
	if (keyValue=='')
	{
		alert('请选择订单！');
		return false;
	}
        window.open( URL+"/pick_goods/oid/"+keyValue , '_blank' );
 }

 function tocheck(){
 	 location.href = URL+"/index/order_status/2/status/0";
}
  function print(id){
    var keyValue;
    if (id)
    {
      keyValue = id;
    }else {
      keyValue = getSelectCheckboxValue();
    }
    if (!keyValue)
    {
      alert('请选择批发订单！');
      return false;
    }
	window.open(APP+"/Wholesale/print_sale/id/"+keyValue, '_blank' );
    
 }
</script>
